<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta name="description" content="">
    <meta name="author" content="">    
	<meta name="keywords" content="玩精灵,财经智库">	
	<title>玩精灵后台</title>	
</head>

	<body>
		<div class="container">
		<!-- 主体部分 -->
			<!-- <div class="containermain"> -->
	
						<!-- 右侧内容 -->
						<!-- <div id="rightcontent"> -->
							<div class="rightcontent">
								<!-- 页面导航 -->
								<div class="righttopnav">
									<a class="index">首页></a><a>留言管理</a>
								</div>
								<!-- 操作区 -->
								<div class="caozuodiv">
									<input class="searchinpu" type="text" name="" placeholder="用户名">
									<!-- <a class="originbtn adduser">专栏</a> -->
									<!-- <a class="originbtn adduser">课程</a> -->
									<a class="originborbtn usersear">查询</a>
									
									<!-- <a class="originbtn adduser">+新增</a> -->
								</div>

								<!-- 数据table -->
								<div class="contenttable">
									
									<table id="table01" class="table01">
										<colgroup>
										 <col class="item-list-col0">
										 <col class="item-list-col1">
										 <col class="item-list-col2">
										 <col class="item-list-col3">
										 <col class="item-list-col4">
										 <col class="item-list-col5">
										 <col class="item-list-col6">
										 </colgroup>
										<tr>
											<th>图片</th>
											<th>标题</th>
											<th>地址</th>
											<th>状态</th>
											<th>创建时间</th>
											<th>操作</th>
										</tr>
										<tr>
											<td><img src="../images/111.png"></td>
											<td>五一活动</td>
											<td>http://www.caijingwulin.com/index.html</td>
											<td>已启用</td>	
											<td>2018-03-29</td>
											<td><a class="tab_editor"></a><a class="tab_del"></a></td>
										</tr>									
										<tr>
											<td><img src=""></td>
											<td>五一活动</td>
											<td>http://www.caijingwulin.com/index.html</td>
											<td>已启用</td>	
											<td>2018-03-29</td>
											<td><a class="tab_editor"></a><a class="tab_del"></a></td>
										</tr>
									</table>
								</div>

								<!-- 翻页 -->
								<div class="pages">
									<a class="pre"><</a>
									<ul class="pagesul">
										<li class="pagesnum thispage">1</li>
										<li class="pagesnum">总共1页</li>
									</ul>
									<a class="next">></a>

								</div>
							</div>
						
						<!-- 用户编辑框 -->
						<div class="zhezhaodiv"></div>
						<div class="editordiv">
							<!-- 页面导航 -->
								<div class="righttopnav">
									新增/编辑
								</div>

								<!-- 数据table -->
								<div class="contenttable">
									
									<div id="table01">										
										<div class="table_user">
											<label class="add_lable">用户名称</label>
											<input class="table_inp" id="loginName" type="text" name=""/>
										</div>					
										<div class="table_user">
											<label class="add_lable">手机号</label>
											<input class="table_inp" id="phone" type="text" name=""/>
										</div>				
										<!-- <div class="table_user">
											<label class="add_lable">设置权限</label>	
											<label class="labelp"><input type="radio" name="abcd" value="4" checked><i>✓</i>系统管理员</label>	
											<label class="labelp"><input type="radio" name="abcd" value="3"><i>✓</i>运维</label>
											<label class="labelp"><input type="radio" name="abcd" value="2"><i>✓</i>客服</label> 
											<label class="labelp"><input type="radio" name="abcd" value="1"><i>✓</i>管理员</label>
										</div>	 -->
										<div class="table_user">
											<label class="add_lable">状态</label>	
											<label class="labelp"><input type="radio" name="abc" value="Y" checked disabled><i>✓</i>启用</label>
											<label class="labelp"><input type="radio" name="abc" value="N" disabled><i>✓</i>停止</label><br>  
	
										</div>	
										<div class="btns">
											<a class="originbtn adduserbtn">确定</a>
											<a class="whitebtn backbtn">返回</a>
										</div>	
									</div>
								</div>
						</div>
		<!-- 	</div> -->
			
		<!-- </div> -->
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script> 
<script type="text/javascript" src="js/jquerysession.js"></script>
<script type="text/javascript">
// window.onload=function(){	

 $(document).ready(function() {  
        // val()无参数是取值，有参数是设置  
        // 为了更好的兼容性，将下面的val()设置与input中的placeholder的值设置相同  
        $("input.searchinpu").val("请输入完整课程名");  
        textFill($('input.searchinpu'));  
    }); 
var urank = $.session.get("rank");
console.log("banner管理");
	$(".navli").click(function(){
		$(this).addClass('select').siblings().removeClass('select');					
	});
	
//添加新数据
$(".adduser").click(function(){
	console.log("新增作者");
		window.location.href='author/authornew.html';
});


//返回
$(".backbtn").click(function(){
	if(ison){
		if(ison){
		ison = false;
		zhezhao(ison);
	}else{
		ison = true;
		zhezhao(ison);
	}
	}
});
//确认
var sid = '';//用户存储用户id
$(".adduserbtn").click(function(){
	console.log('确认');
	if(ison){
		if(ison){
		ison = false;
		zhezhao(ison);
		}else{
			ison = true;
			zhezhao(ison);
		}
	}
	
		console.log(sid);
		$.ajax({
			type: "get",
			url: url+"account/edit",
			data:{
				'sid': sid
			},
			success: function(data){
				console.log(data);
				var useredit = data.data.account;
				if (data.code=='2000') {
					$("#loginName").val(useredit.name);
					$("#phone").val(useredit.mobile);
					$("input[name='abc']:checked").val("Y");

				}else{
					console.log('系统错误');
				}
			}
		})

		if(ison){
			ison = false;
			zhezhao(ison);
		}else{
			ison = true;
			zhezhao(ison);
		}
							

});

$(".usersear").click(function(){
	usersear();
});

//用户搜索
function usersear(){	
	var searchinpu = String($(".searchinpu").val());
	console.log($(".searchinpu").val());
	console.log(searchinpu);
	if(searchinpu.length!=0){
			$.ajax({
		type: "get",
		url: url+"account/showByName",
		data:{
			'name': searchinpu
		},
		success: function(data){
			if(data.code == '2000'){
				var userlist = data.data;//用户列表数据
				var userhtml = '<colgroup>'
										 +'<col class="item-list-col0">'
										 +'<col class="item-list-col1">'
										 +'<col class="item-list-col2">'
										 +'<col class="item-list-col3">'
										 +'<col class="item-list-col4">'
										 +'<col class="item-list-col5">'
										 +'<col class="item-list-col6">'
										 +'</colgroup>'
										+'<tr>'
											+'<th>图片</th>'
											+'<th>标题</th>'
											+'<th>地址</th>'
											+'<th>状态</th>'
											+'<th>创建时间</th>'
											+'<th>操作</th>'
										+'</tr>';
							for(var i in userlist){
								var usertime = timeStamp2String(parseInt(userlist.createdDatetime));
								var usid = userlist.sid;
								//创建时间
								id = 0; //序号归零 
								id++;
								
								userhtml += '<tr>'+
											'<td></td>'+
											'<td>'+userlist.name+'</td>'+
											'<td>手机号</td>'+
											'<td>'+userlist.mobile+'</td>'+	
											'<td>启用</td>'+
											'<td>'+usertime+'</td>'+
											'<td><a class="tab_editor" sid="'+usid+'"></a><a class="tab_del" sid="'+usid+'"></a></td>'+
											'</tr>';
											
							}
							$("#table01").html('');
							$("#table01").append(userhtml);
							console.log('数据成功加载');
			}else{

			}
			
		}
	})
	}else{
		alert("请完整输入课程名");
	}

}

				// banner列表数据
				// var id = 0;//序号
				// var newpage = 0; //当前页面
				// var pagesize = 6; //每页条数

				userinfo();
				function userinfo(){
				$.ajax({
					type: "get",
					url: url+"banner/showAllBanner",
					success: function(data){
						if(data.code=='2000'){
							var userlist = data.data;//用户列表数据
							// var pageable = data.data.pageable; //用户翻页
							// var totalElements = data.data.totalElements; //总条数
							// var pageNumber = pageable.pageNumber;//当前第几页
							// var totalPages = data.data.totalPages;//总页数
							var userhtml = '<colgroup>'
										 +'<col class="item-list-col0">'
										 // +'<col class="item-list-col1">'
										 // +'<col class="item-list-col2">'
										 // +'<col class="item-list-col3">'
										 +'<col class="item-list-col4">'
										 +'<col class="item-list-col5">'
										 // +'<col class="item-list-col6">'
										 +'</colgroup>'
										+'<tr>'
											+'<th>专题</th>'
											+'<th>课程名称</th>'
											+'<th>用户名</th>'
											+'<th>评论内容</th>'
											+'<th>点赞数</th>'
											// +'<th>作者是否推荐</th>'
											// +'<th>操作</th>'
										+'</tr>';
							for(var i in userlist){
								var usertime = timeStamp2String(parseInt(userlist[i].createdDatetime));
								var usid = userlist[i].sid;
								//状态
								if( userlist[i].sortBy=='1' ){
									zhuangt ='已启用';
								}else if( userlist[i].sortBy == '2' ){
									zhuangt ='未启用';	
								}else{
									zhuangt = '不明';
								}
								//创建时间								
								// id++;	
								userhtml += '<tr>'+
											// '<td><img src="'+userlist[i].imageUrl+'"></td>'+
											'<td>'+userlist[i].title+'</td>'+
											// '<td>'+userlist[i].articleSid+'</td>'+											
											'<td>'+zhuangt+'</td>'+
											// '<td>'+timeStamp2String(userlist[i].createdDatetime)+'</td>'+
											'<td>'+timeStamp2String(userlist[i].createdDatetime)+'</td>'+
											'<td>'+timeStamp2String(userlist[i].createdDatetime)+'</td>'+
											'<td>'+timeStamp2String(userlist[i].createdDatetime)+'</td>'+

											// '<td><a class="tab_editor" artsid="'+userlist[i].articleSid+'" sid="'+usid+'"></a><a class="tab_del" sid="'+usid+'"></a></td>'+
											// '</tr>';
											// '<td><a class="tab_editor1" artsid="'+userlist[i].articleSid+'" sid="'+usid+'"></a><a class="tab_del1" sid="'+usid+'"></a></td>'+
											'</tr>';
											
											
							}
							$("#table01").html('');
							$("#table01").append(userhtml);
							console.log('数据成功加载');

							// //编辑banner信息
							// $(".tab_editor").click(function(){
							// 	// window.location.href='marketingmar/editorbanner.html?artilcesid='+$(this).attr('artsid')+'&bannersid='+$(this).attr('sid');
							// 	window.location.href='author/authoramend.html?bannersid='+$(this).attr('sid')+'&artilcesid='+$(this).attr('artsid');
							// });

							// // 删除事件
							// $(".tab_del").click(function(){
							// 	console.log(typeof $(this).attr('sid'));
							// 	$.ajax({
							// 		type: "post",
							// 		url: url+"banner/removeBanner",
							// 		data:{
							// 			'bannerSid': $(this).attr('sid'),
							// 			'rank': urank
							// 		},
							// 		success: function(data){
							// 			if (data.code == '2000') {
							// 				alert('删除成功');
							// 				userinfo();
							// 			}else{
							// 				console.log('删除失败');
							// 			}
							// 		}
							// 	});
							// });
							//遮罩层弹窗							
							zhezhao(ison);

						}else{
							console.log('系统错误');
						}
						
					}
				});
		}
		
</script>
<!-- </body>
	</html>